package dji.ux.ext.panel.camera;

import androidx.annotation.NonNull;

import dji.common.camera.SettingsDefinitions;
import dji.sdk.camera.Camera;
import dji.sdk.camera.Lens;
import dji.sdk.sdkmanager.DJISDKManager;
import dji.ux.beta.base.DJISDKModel;
import dji.ux.beta.base.WidgetModel;
import dji.ux.beta.base.uxsdkkeys.ObservableInMemoryKeyedStore;


/**
 * Widget Model for the {@link CameraH20TZoomModel} used to define
 * the underlying logic and communication
 */
class CameraH20TZoomModel extends WidgetModel {


    CameraH20TZoomModel(@NonNull DJISDKModel djiSdkModel,
                        @NonNull ObservableInMemoryKeyedStore keyedStore) {
        super(djiSdkModel, keyedStore);
    }

    boolean isH20TCamera(){
        if (DJISDKManager.getInstance().getProduct() == null ||
                DJISDKManager.getInstance().getProduct().getCamera() == null)
            return false;

        String cameraName = DJISDKManager.getInstance().getProduct().getCamera().getDisplayName();
        return cameraName.endsWith(Camera.DisplayNameZenmuseH20) || cameraName.equals(Camera.DisplayNameZenmuseH20T);
    }

    Lens getZoomLens(){
        if (DJISDKManager.getInstance().getProduct() == null ||
                DJISDKManager.getInstance().getProduct().getCamera() == null ||
                DJISDKManager.getInstance().getProduct().getCamera().getLenses() == null) {
            return null;
        }

        for (Lens lens : DJISDKManager.getInstance().getProduct().getCamera().getLenses()) {
            if (lens.getType() == SettingsDefinitions.LensType.ZOOM) {
                return lens;
            }
        }

        return null;
    }


    @Override
    protected void inSetup() {

    }

    @Override
    protected void inCleanup() {
        //Nothing to cleanup
    }

    @Override
    protected void updateStates() {
        //Nothing to update
    }


}
